package com.gdth.widget.calendar;

import java.io.Serializable;

/**
 * 日期实体
 * @author Arvin
 *
 */
public class CalendarItem implements Serializable{
	
	private static final long serialVersionUID = 1L;
	
	/**
	 * 年
	 */
	public int year;
	
	/**
	 * 月
	 */
	public int month;
	
	/**
	 * 日
	 */
	public int day;
	
	/**
	 * 周
	 */
	public int week;
	
	/**
	 * 计算的日期
	 * @param year
	 * @param month
	 * @param day
	 */
	public CalendarItem(int year,int month,int day){
		if(month > 12){
			month = 1;
			year++;
		}else if(month < 1){
			month = 12;
			year--;
		}
		this.year = year;
		this.month = month;
		this.day = day;
	}
	
	/**
	 * 当前日期
	 */
	public CalendarItem(){
		this.year = DateUtil.getYear();
		this.month = DateUtil.getMonth();
		this.day = DateUtil.getCurrentMonthDay();
	}
	
	/**
	 * 获取同年同月的CalendarItem实体
	 * @param date
	 * @param day
	 * @return
	 */
	public static CalendarItem modifiDayForObject(CalendarItem date, int day){
		CalendarItem modifiDate = new CalendarItem(date.year,date.month,day);
		return modifiDate;
	}
	
	/**
	 * Serializable接口，用于格式化时间
	 */
	@Override
	public String toString() {
		return year+"-"+month+"-"+day;
	}

	
	/**********************年、月、日、周的Get、Set函数*************************/
	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}

	public int getWeek() {
		return week;
	}

	public void setWeek(int week) {
		this.week = week;
	}
}
